import 'package:backend.core/core/domain/entities/api/google_play/api_google_play_transaction_revocation_info.dart';
import 'package:backend.core/core/domain/entities/google_play/google_play_transaction_revocation_info.dart';
import 'package:backend.purchases/domain/helpers/api/google_play/create_api_google_play_purchased_item_revocation_reason_from_internal_one.dart';
import 'package:backend.purchases/domain/helpers/api/google_play/create_api_google_play_purchased_item_revocation_source_from_internal_one.dart';

abstract class CreateApiGooglePlayTransactionRevocationInfoFromInternalOne {
  ApiGooglePlayTransactionRevocationInfo call({
    required GooglePlayTransactionRevocationInfo revocationInfo,
  });
}

class CreateApiGooglePlayTransactionRevocationInfoFromInternalOneImpl
    implements CreateApiGooglePlayTransactionRevocationInfoFromInternalOne {
  const CreateApiGooglePlayTransactionRevocationInfoFromInternalOneImpl({
    required CreateApiGooglePlayTransactionRevocationSourceFromInternalOne
        createApiGooglePlayTransactionRevocationSourceFromInternalOne,
    required CreateApiGooglePlayTransactionRevocationReasonFromInternalOne
        createApiGooglePlayTransactionRevocationReasonFromInternalOne,
  })  : _createApiGooglePlayTransactionRevocationSourceFromInternalOne =
            createApiGooglePlayTransactionRevocationSourceFromInternalOne,
        _createApiGooglePlayTransactionRevocationReasonFromInternalOne =
            createApiGooglePlayTransactionRevocationReasonFromInternalOne;

  final CreateApiGooglePlayTransactionRevocationSourceFromInternalOne
      _createApiGooglePlayTransactionRevocationSourceFromInternalOne;
  final CreateApiGooglePlayTransactionRevocationReasonFromInternalOne
      _createApiGooglePlayTransactionRevocationReasonFromInternalOne;

  @override
  ApiGooglePlayTransactionRevocationInfo call({
    required GooglePlayTransactionRevocationInfo revocationInfo,
  }) {
    final source = _createApiGooglePlayTransactionRevocationSourceFromInternalOne(
      source: revocationInfo.source,
    );

    final reason = _createApiGooglePlayTransactionRevocationReasonFromInternalOne(
      reason: revocationInfo.reason,
    );

    return ApiGooglePlayTransactionRevocationInfo(
      source: source,
      reason: reason,
      time: revocationInfo.time,
    );
  }
}
